package blockingQueue;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.TimeUnit;

/**
 * @program: javase
 * @description:
 * @author: lld
 * @create: 2021-04-18 21:25
 **/
public class Test1 {
    public static void main(String[] args) throws InterruptedException {
        SynchronousQueue<String> objects = new SynchronousQueue<>();
//        ArrayBlockingQueue<String> objects = new ArrayBlockingQueue<>(3);
//        满了返回异常
        System.out.println("objects.add(\"a\") = " + objects.add("a"));

//        阻塞等待
//        objects.put("b");
//        满了返回false,不返回异常
        System.out.println("objects.offer(\"c\") = " + objects.offer("c"));
        //超时等待
        objects.offer("c", 4, TimeUnit.SECONDS);

    }
}
